{include file="common/head"}
    <style>
        a{text-decoration:none;}
        input{display:initial!important;}
    </style>
</head>
<body >
<div class="container-fluid">
    <form action="/index.php/order/index" method="post">

    <div class="row" id="query_bar" style="height: 50px;line-height: 50px;">
        <input type="hidden" name="status" value="{$status}"/>
        <div class="col">
            <label for="type" >订单类型：</label>
            <select name="type" class="form-control" style="width:140px;display:initial;">
                <option value="">所有</option>
                {foreach $types as $k=>$v}
                    <option value="{$k}" {if $type==$k}selected{/if}>{$v}</option>
                {/foreach}
            </select>

            <label for="dept_id" >仓库：</label>
            <select name="dept_id" class="form-control" style="width:140px;display:initial;">
                <option value="">所有</option>
                {foreach $dept as $k=>$v}
                    <option value="{$v['id']}" {if $dept_id==$v['id']}selected{/if}>{$v['name']}</option>
                {/foreach}
            </select>

            <label for="sdate" >日期：</label>
            <input class="form-control" type="text" value="" id="sdate" name="sdate" placeholder="开始日期" />
            
            <label for="sdate" >
                <input class="form-control" type="text" value="" id="edate" name="edate" placeholder="结束日期" />
            </label>    
            <label for="order_no" >订单号：</label>
                <input class="form-control" type="text" value="" id="order_no" name="order_no" placeholder="订单号" />
            </label>

            <button type="button" class="btn btn-warning query"  >
                <span class="bi-search" ></span>
            </button>
        </div>

    </div>
    </form>

    <table class="table table-sm table-hover table-striped" style="">
        
        <thead class="table-info">
            <th>序号</th>
            <th>单号</th>
            <th>单类型</th>
            <th>商品</th>
            <th>价格</th>
            <th>客户</th>
            <th>推广人</th>
            <th>佣金</th>
            <th>下单时间</th>
            <th>仓库</th>
            <th>备注</th>
            <th>状态</th>
            <th>快递单号</th>
            <th>

            </th>
        </thead>
        <tbody>
            {foreach $list['data'] as $k=>$kv}
            <tr>
                <td>{$k+1}</td>
                <td style="width:240px;">{$kv['order_no']}</td>
                <td>{$kv['type_name']}</td>
                <td style="width:300px;word-break:break-word;">{$kv['goods_list']}</td>
                <td>{$kv['price1']}</td>
                <td>{$kv['customer_id_name']}</td>
                <td>{$kv['share_id_name']}</td>
                <td>{$kv['commision']}</td>
                <td>{$kv['create_time']}</td>
                <td>{$kv['dept_id_name']}</td>
                <td>{$kv['memo']}</td>  
                <td>{$kv['status_name'][0]}</td>
                
                <td>
                    {if $kv['status']==2}
                    
                    <button tyle="button" class="btn btn-sm btn-warning send" oid="{$kv['id']}" >
                        <span class="bi-plus-lg"></span>发货
                    </button>
                    {else}
                        {$kv['package_no']}
                    {/if}
                </td>

                <td class="text-nowrap">
<!--                     <button tyle="button" class="btn btn-sm btn-info">
                        <span class="bi-card-list" oid="{$kv['id']}"></span>
                    </button> -->
                    <button tyle="button" class="btn btn-sm btn-info" oid="{$kv['id']}">
                        <span class="bi-info" ></span>&nbsp;
                    </button>         

                    {if $kv['status']<10}
                    <button tyle="button" class="btn btn-sm btn-danger btn_cancel"  oid="{$kv['id']}">
                        <span class="bi-trash"></span>
                    </button>
                    {/if}
              
                </td>
            </tr>
            {/foreach}

        </tbody>    
    </table>
    {include file="common/pagination"}
</div>

</body>

<script type="text/javascript">
  
  $(document).ready(function(){
    setTimeout(function(){$(".query").show()},3000);

    $(".bi-card-list").on('click',function(){
        var oid =$(this).attr('oid');
        layer.open({
          type: 2,
          title: '订单明细',
          shadeClose: true,
          shade: false,
          maxmin: true, //开启最大化最小化按钮
          area: ['500px', '600px'],
          content: '/index.php/order/order_list/id/'+oid
        });
    })

    $(".btn-info").on('click',function(){
        var oid =$(this).attr('oid');
        layer.open({
          type: 2,
          title: '订单记录',
          shadeClose: true,
          shade: false,
          maxmin: true, //开启最大化最小化按钮
          area: ['700px', '600px'],
          content: '/index.php/order/order_log/id/'+oid
        });
    })

    $(".bi-check").on('click',function(){
        var oid=$(this).attr('oid');
        layer.confirm('确认订单吗？', {
          btn: ['Yes','No'] //按钮
        }, function(){

          $.post("/index.php/order/order_check/id/"+oid,{id:oid},function(res){

          });

        }, function(){
            layer.msg('取消操作!');
        });
    })

    $(".send").on('click',function(){
        var package_no=prompt("请输入快递单号或者输入【自行配送】");
        if(!package_no) {
            layer.msg('请输入快递单号或者输入【自行配送】!');
            return;
        }

        layer.msg(package_no);
        var oid =$(this).attr('oid');
        layer.confirm('是否确认发货？', {
          btn: ['确认','不'] //按钮
        }, function(){
          $.post("/index.php/order/order_takex/id/"+oid,{id:oid,status:3,package_no:package_no},function(res){
                layer.msg(res.msg);
          });

        }, function(){
            layer.msg('操作取消!');
        });
    })    



    $(".btn_cancel").on('click',function(){
        var oid=$(this).attr('oid');
        layer.confirm('确认取消订单吗？', {
          btn: ['Yes','No'] //按钮
        }, function(){

          $.post("/index.php/order/order_cancel",{id:oid},function(res){
            console.log(res.msg)
            layer.msg(res.msg);
          });

        }, function(){
            layer.msg('取消操作!');
        });

    })


    $(".query").on('click',function(){
        var cid = $("#customer_id").val();
        var order_no = $("#order_no").val();
        var sdate = $("#sdate").val();
        var edate = $("#edate").val();
        $("form").submit();
    })

     
  })



</script>

</body>
</html>
